# dddd验证码识别.py
from io import BytesIO
from PIL import Image
import ddddocr
import requests

ocr = ddddocr.DdddOcr(show_ad=False)  # 切换为第二套ocr模型
url = 'https://pic.616pic.com/ys_bnew_img/00/42/61/V3N7MK0v8e.jpg'

response = requests.get(url)
response.raise_for_status()  # 如果请求失败, 抛出异常 HttpError
print(response.headers['Content-Type'])  # 输出图片类型

img2 = Image.open(BytesIO(response.content))
img2.save('yanzhengma.jpg', format='JPEG')  # 保存以验证

result = ocr.classification(img2)
print(result)
